package com.ymatou.smstransfer.api.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.smstransfer.api.parameter.SendSmsBean;
import com.ymatou.smstransfer.api.service.SendSmsCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
/**
*发送短信
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SendSms{
	private static SendSmsBean sendsmsBean;
	private static SendSmsCall sendsmsCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("发送短信");
	}

	@Before
	public void caseUp() {
		sendsmsBean=new SendSmsBean();
		sendsmsCall=new SendSmsCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(sendsmsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
//	@Ignore
	public void Tc_SendSms_001() {
		Logger.start(true,"发送短信成功");
		try {
			//TODO 验证真实手机是否收到短信 不带86收不到
			sendsmsBean.setLanguage("zh-cn");
			sendsmsBean.setPhoneNumber("8613585777478");
			sendsmsBean.setVerifyCode("1111");
			sendsmsBean.setMessageTemplate("短信测试:$$CODE$$");
//			sendsmsCall.setData(FormatUtil.beanToHttpString(sendsmsBean, true));
			sendsmsCall.setData(sendsmsBean);
			sendsmsCall.callService();
//			{"VerifyInfo":{"CodeState":3,"CodeEntered":""},"RawResponse":"{\"resource_uri\": \"/v1/verify/656FD9196F580F0490466DA9681C4D7C\", \"reference_id\": \"656FD9196F580F0490466DA9681C4D7C\", \"sub_resource\": \"sms\", \"errors\": [], \"verify\": {\"code_state\": \"UNKNOWN\", \"code_entered\": \"\"}, \"status\": {\"updated_on\": \"2017-05-11T06:50:57.918863Z\", \"code\": 290, \"description\": \"Message in progress\"}}","ReferenceId":"656FD9196F580F0490466DA9681C4D7C","ResourceUri":"/v1/verify/656FD9196F580F0490466DA9681C4D7C","SubResource":"sms","Errors":[],"Status":{"UpdatedOn":"2017-05-11T06:50:57.918863Z","Code":290,"Description":"Message in progress"}}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}